<%@ page import="java.util.Enumeration" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
</head>
<body>
<c:import url="/checkLogin.jsp"/>


<p align="center">
    <a href="toAddstudent">新增学生</a>
</p>
<%--<%
    Enumeration<String> names = request.getAttributeNames();
    while(names.hasMoreElements()){
        String key=names.nextElement();
        Object value=request.getAttribute(key);
        out.print("<h6>"+key+":"+value+"</h6>");
    }
%>--%>
<p align="center">
<form action="studentServlet">
    <input type="search" value="${sname}" name="sname" placeholder="输入学生名来搜索"/>
    <input type="search" value="${qq}" name="qq" placeholder="输入qq号来搜索"/>
    <input type="search" value="${wechat}" name="wechat" placeholder="输入学生微信号来搜索"/>
    入学时间从<input type="date" value="<fmt:formatDate value='${dateStart}' pattern='yyyy-MM-dd'/>" name="dateStart" placeholder="起始"/>-<input type="date" value='<fmt:formatDate value="${dateEnd}" pattern="yyyy-MM-dd"/>' name="dateEnd" placeholder="终止"/>
    <input type="submit" value="查找"/>
</form>
</p>
<p style="color:red">
${msg}
<c:remove var="msg"/>
</p>
<table border="1" cellspacing="0" cellpadding="0">
    <caption>学生列表</caption>
    <tr>
        <th>学号</th><th>姓名</th><th>性别</th><th>电话</th><th>qq</th><th>微信</th><th>年级</th><th>入学时间</th><th>来自哪里</th><th>生日</th><th>家庭住址</th>
        <th colspan="5">操作</th>
    </tr>
    <c:forEach items="${pages.datas}" var="s" >
        <tr>
            <td>${s.stuno}</td>
            <td>${s.sname}</td>
            <td>${s.sex}</td>
            <td>${s.telephone}</td>
            <td>${s.qq}</td>
            <td>${s.wechat}</td>
            <td>${s.gradeid}</td>
            <td><fmt:formatDate pattern="yyyy年MM月dd日" value="${s.enterdate}"/></td>
            <td>${s.fromcity}</td>
            <td><fmt:formatDate pattern="yyyy/MM/dd" value="${s.birthday}"/></td>
            <td>${s.address}</td>
                <%-- <td><%=s.getPass()%></td>
                 <td><img src="images/<%=s.getIdcardpic()%>" height="40px" width="80px" alt="没有"/></td>--%>
            <td><a href="9.4/job2-1.jsp?stuno=${s.stuno}">修改</a></td>
            <%--<td><a href="delStudent.jsp?id=${s.stuno}" onclick="return confirm('真的删除${s.stuno}?')">删除</a></td>--%>
            <td><a href="delStudent?stuno=${s.stuno}" onclick="return confirm('真的删除${s.stuno}?')">删除</a></td>
            <%--<td><a href="showStudent?stuno=${s.stuno}">详情</a></td>--%>
            <td><a href="showStudent/${s.stuno}">详情</a></td>
            <td><a href="#">添加成绩</a></td>
            <td><a href="findStudentScore?stuno=${s.stuno}" title="查看这个学生的考过所有科目成绩">查看成绩</a></td>
        </tr>
    </c:forEach>

</table>
<p align="center">
    <a href="studentServlet?p=1&sname=${sname}&qq=${qq}&wechat=${wechat}&dateStart=<fmt:formatDate value='${dateStart}' pattern='yyyy-MM-dd'/>&dateEnd=<fmt:formatDate value='${dateEnd}' pattern='yyyy-MM-dd'/>">首页</a>

    <c:if test="${pages.pageNo > 1}">
    <a href="studentServlet?p=${pages.pageNo-1}&sname=${sname}&qq=${qq}&wechat=${wechat}&dateStart=<fmt:formatDate value='${dateStart}' pattern='yyyy-MM-dd'/>&dateEnd=<fmt:formatDate value='${dateEnd}' pattern='yyyy-MM-dd'/>">上一页</a>
    </c:if>
    <input type="number" value="${pages.pageNo}" min="1" max="${pages.totalPage}" name="goto" style="width: 45px" size="3"/>
    /${pages.totalPage}
    <input type="button" value="Go" id="go"/>
   <c:if test="${pages.pageNo<pages.totalPage}">
    <a href="studentServlet?p=${pages.pageNo+1}&sname=${sname}&qq=${qq}&wechat=${wechat}&dateStart=<fmt:formatDate value='${dateStart}' pattern='yyyy-MM-dd'/>&dateEnd=<fmt:formatDate value='${dateEnd}' pattern='yyyy-MM-dd'/>">下一页</a>
   </c:if>
    <a href="studentServlet?p=${pages.totalPage}&sname=${sname}&qq=${qq}&wechat=${wechat}&dateStart=<fmt:formatDate value='${dateStart}' pattern='yyyy-MM-dd'/>&dateEnd=<fmt:formatDate value='${dateEnd}' pattern='yyyy-MM-dd'/>">尾页</a>
</p>
<script>
    $(function () {
        $("#go").click(function () {
            var np=$(this).prev().val();
            //不能比totalPage
            window.location.replace("studentServlet?p="+np+"&sname=${sname}&qq=${qq}&wechat=${wechat}&dateStart=<fmt:formatDate value='${dateStart}' pattern='yyyy-MM-dd'/>&dateEnd=<fmt:formatDate value='${dateEnd}' pattern='yyyy-MM-dd'/>");
        });
    });
</script>
</body>
</html>
